<template>
  <section class="banner-container">
    <Category></Category>
    <section class="banner-wrapper">
      <n-carousel :interval="5000" autoplay>
        <router-link v-for="item in bannerItems.items" :to="'/product/' + item.pro_no">
          <img class="carousel-img" :src="item.src" />
        </router-link>
      </n-carousel>
    </section>
  </section>
  <section class="sub-banner-container">
    <router-link
      class="sub-banner"
      v-for="item in bannerItems.items"
      :to="'/product/' + item.pro_no"
    >
      <img class="banner-img" :src="item.src" />
    </router-link>
  </section>
</template>
<script setup lang="ts">
import { reactive } from '@vue/reactivity';
import { getBanner } from '../../api/productApi';
import Category from './Category.vue';
const bannerItems: any = reactive({
  items: []
});
getBanner().then(res => {
  bannerItems.items = res.data || [];
})
</script>
<style scoped>
.banner-container {
  height: 540px;
  position: relative;
  box-shadow: 0 0 18px 3px #7f7f7f33;
  width: 1226px;
  min-width: 1226px;
  margin: 0 auto;
}
.banner-wrapper {
  position: relative;
}
.carousel-img {
  width: 100%;
  height: 540px;
  object-fit: cover;
}

.sub-banner-container {
  height: 200px;
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  width: 100%;
  width: 1226px;
  min-width: 1226px;
  margin: 20px auto 0;
}

.sub-banner {
  flex: 1;
  transition: 0.3s ease all;
}

.sub-banner:hover {
  box-shadow: 2px 8px 18px #3f3f3f33;
  transform: translateY(-5px);
}

.sub-banner + .sub-banner {
  margin-left: 20px;
}

.sub-banner .banner-img {
  object-fit: cover;
  width: 100%;
  height: 100%;
}
</style>